home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / c / agawhitefade.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  3.0 KB  |  102 lines

  1. /*
  2. ** AGA WhiteFade Demo
  3. ** ------------------
  4. ** There are three examples of fading in this program:  FadeToWhite,
  5. ** FadeToPalette, and FadeToBlack.
  6. **
  7. ** FadeToWhite is called as soon as you run the executable, then it fades
  8. ** to the palette and then to black.
  9. **
  10. ** Compiles under SAS/C
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15.  
  16. #include <exec/memory.h>
  17. #include <games/games.h>
  18. #include <proto/games.h>
  19. #include <proto/exec.h>
  20.  
  21. struct GMSBase *GMSBase;
  22.  
  23. #define AMT_PLANES 5
  24.  
  25. ULONG Palette[] = {
  26.       0x000000,0x080808,0x101010,0x191919,0x212121,0x292929,0x313131,
  27.       0x3A3A3A,0x424242,0x4A4A4A,0x525252,0x5A5A5A,0x636363,0x6B6B6B,
  28.       0x737373,0x7B7B7B,0x848484,0x8C8C8C,0x949494,0x9C9C9C,0xA5A5A5,
  29.       0xADADAD,0xB5B5B5,0xBDBDBD,0xC5C5C5,0xCECECE,0xD6D6D6,0x7F7F7F,
  30.       0x9B9B9B,0x707070,0x444444,0x1E1E1E
  31.       };
  32.  
  33. struct GameScreen GameScreen = {
  34.        GSV1,                /* Structure version */
  35.        0,0,0,               /* Screen_Mem1,2,3 */
  36.        0,                   /* ScreenLink */
  37.        0,                   /* Adress of palette */
  38.        0,                   /* Address of rasterlist */
  39.        32,                  /* Amount of colours */
  40.        320,256,320,256,     /* Screen & Pic Height/Width */
  41.        AMT_PLANES,          /* Amount of bitplanes */
  42.        0,0,                 /* Top Of Screen Offset, X/Y */
  43.        0,0,                 /* X/Y counters (for scrolling) */
  44.        0,                   /* Special attributes */
  45.        LORES|COL24BIT,      /* Screen mode */
  46.        INTERLEAVED,         /* Screen type */
  47.        0                    /* Reserved */
  48.        };
  49.  
  50. struct Picture Picture = {
  51.        PCV1,                /* Version header */
  52.        0,                   /* Destination */
  53.        320,256,             /* Width, Height */
  54.        AMT_PLANES,          /* Amount of Planes */
  55.        32,                  /* Amount of colours */
  56.        &Palette,            /* Palette (remap) */
  57.        LORES|COL24BIT,      /* Screen mode */
  58.        INTERLEAVED,         /* Destination */
  59.        0                    /* Parameters */
  60.        };
  61.  
  62. struct GameScreen *OurScreen = &GameScreen;
  63. struct Picture *LoadingPic = &Picture;
  64.  
  65. /*=========================================================================*/
  66.  
  67. void main(void)
  68. {
  69.    UWORD FadeState = 0;
  70.  
  71.    struct GamesLibrary *GMSBase = (struct GamesLibrary *)
  72.       OpenLibrary("games.library", 0);
  73.  
  74.    SetUserPri();
  75.  
  76.    if (Add_Screen(OurScreen) == NULL) {
  77.  
  78.       LoadingPic->Data = OurScreen->MemPtr1;
  79.       if (LoadPic("GAMESLIB:data/IFF.Loading",LoadingPic) == NULL) {
  80.          Show_Screen(OurScreen);
  81.  
  82.          do { Wait_OSVBL();            
  83.               FadeState = B24_FadeToWhite(OurScreen,FadeState,10);
  84.          } while (FadeState != NULL);
  85.  
  86.          do { Wait_OSVBL();
  87.               FadeState = B24_FadeToPalette(OurScreen,FadeState,&Palette,2);
  88.          } while (FadeState != NULL);
  89.  
  90.          Wait_Time(80);
  91.  
  92.          do { Wait_OSVBL();
  93.           FadeState = B24_FadeToBlack(OurScreen,FadeState,2);
  94.      } while (FadeState != NULL);
  95.  
  96.       }
  97.       Delete_Screen(OurScreen);
  98.    }
  99.    CloseLibrary((struct Library *)GMSBase);
  100. }
  101.  
  102.